#!/bin/bash  
  
# Check input.txt
if [ ! -f "input.txt" ]; then  
  echo "Error: File input.txt may do not exist "  
  exit 1  
fi  
  
# Check test
if [ ! -x "test" ]; then  
  echo "Error: The executable file test may do not exist or does not have execute permissions"  
  exit 1  
fi  
  
# Create output
> output  
  
# Process the input file line by line
while IFS= read -r line || [[ -n "$line" ]]; do
  echo "$line" | ./test >> output #Stores result in output
done < input.txt


echo "The calculation result is saved in the file 'output'. " 